package com.example.homework;

import androidx.appcompat.app.AppCompatActivity;



import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private  int score1,score2;

    private TextView out1,out2;
    private Button button1,button2,button3,button4,button5,button6,button7;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        intView();}

        private void intView() {
        out1 = (TextView) findViewById(R.id.out1);
        out2 = (TextView) findViewById(R.id.out2);
        Button button1 = (Button) findViewById(R.id.button1);
        Button button2 = (Button) findViewById(R.id.button2);
        Button button3 = (Button) findViewById(R.id.button3);
        Button button4 = (Button) findViewById(R.id.button4);
        Button button5 = (Button) findViewById(R.id.button5);
        Button button6 = (Button) findViewById(R.id.button6);
        Button button7 = (Button) findViewById(R.id.button7);
            button1.setOnClickListener(this);
            button2.setOnClickListener(this);
            button3.setOnClickListener(this);
            button4.setOnClickListener(this);
            button5.setOnClickListener(this);
            button6.setOnClickListener(this);
            button7.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button1:
                aAddScore(3);

                break;
            case R.id.button2:
                aAddScore(2);

                break;
            case R.id.button3:
                aAddScore(1);

                break;
            case R.id.button4:
                bAddScore(3);

                break;
            case R.id.button5:
                bAddScore(2);

                break;
            case R.id.button6:
                bAddScore(1);

                break;
            case R.id.button7:
                resetScore();
            default:
                break;


        }

    }


    private void aAddScore(int score) {
        score1 = score1 + score;
        displayAScore(score1);
    }
    private void bAddScore(int score) {
        score2 = score2 + score;
        displayBScore(score1);
    }



    private void resetScore() {
        score1 = 0;
        score2 = 0;
        displayAScore(score1);
        displayBScore(score2);
    }


    private void displayAScore(int score) {
        out1.setText(String.valueOf(score));
    }


    private void displayBScore(int score) {
        out2.setText(String.valueOf(score));
    }

}


